< previous page page_503 next page >

Page 503

9f31265bb40b592b1929e18a47ab28e5.gif
   strSQL = strSQL & "bool401k_fl, "
   strSQL = strSQL & "boolBonus_fl, "
   strSQL = strSQL & "iConcurrency_id, "
   strSQL = strSQL & "dtLastUpdate_dt, "
   strSQL = strSQL & "sLastUpdate_id "
   strSQL = strSQL & "FROM tblEmployees "
   strSQL = strSQL & "WHERE lEmp_id = " & _
                     lstNames.ItemData(lstNames.ListIndex)

   If moRS.State = adStateOpen Then
      moRS.Close
   End If

   moRS.Open strSQL, goConn, _
             adOpenKeyset, adLockPessimistic, adCmdText

   If moRS.EOF Then
      FormFind = False
   Else
      FormFind = True
   End If
End Function
The FormFind() function uses the module-level recordset you created in the Form_Load() event. It builds the SELECT statement with the WHERE clause, as shown in the following code:
9f31265bb40b592b1929e18a47ab28e5.gif
strSQL = strSQL & "WHERE lEmp_id = " & _
                  lstNames.ItemData(lstNames.ListIndex)
The value in the ItemData() property is retrieved and concatenated onto the SQL statement to find the particular employee selected. Then the WHERE clause loads a one-row recordset thats used to display the employee data in the appropriate controls on the right side of the form. This one-row recordset is opened as a keyset type to allow for the editing of this employee data. Once the module-level recordset has been opened with this one employee record, its now time to call the FormShow procedure to display the employee data.

 
< previous page page_503 next page >

If you like this book, buy it!